package com.laicunba.ext.activity.act20170424;

import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.laicunba.pojo.ActivityDO;
import com.laicunba.pojo.ActivityJoinDO;
import com.laicunba.pojo.UserDO;
import com.laicunba.service.ActivityJoinService;
import com.laicunba.service.activity.ActivityRewardService;
import com.laicunba.util.AssertUtil;

//@Service
public class Act20170424JoinRewardService implements ActivityRewardService {

	@Override
	public String getType() {
		return "killdragon13";
	}

	@Autowired
	private ActivityJoinService activityJoinService;

	@Override
	public boolean doReward(UserDO userDO, ActivityDO activityDO, ActivityJoinDO joinDO) {
		if (!"20170424".equalsIgnoreCase(activityDO.getId()) || !"013".equalsIgnoreCase(joinDO.getSubActId())) {
			return false;
		}
		joinDO = activityJoinService.get(ActivityJoinDO.class, joinDO.getId());
		joinDO.setRewardResp(String.valueOf((char)(new Random().nextInt(4) + 65)));
		AssertUtil.assertTrue(activityJoinService.updateSkipCheckOwner(joinDO), "REWARD_FAIL");
		return true;
	}
}
